#ifndef __LOGIN_MSG_HANDLER__
#define __LOGIN_MSG_HANDLER__


#include "Message/MsgHandlerLgc.h"
#include "Entity/EntityManagerIf.h"


class  LoginMsgHandler : public MsgHandlerLgc
{
public:
	LoginMsgHandler();
	~LoginMsgHandler();

	virtual bool initialize(IMsgHandlerInitData* data) ;

	virtual bool handleMsg(IMsg* pMsg);
protected:
	//
	//	message from DB 
	void onRcvDBMsg(IMsg* pMsg);

	//
	//	message from client
	void onRcvCliMsg(IMsg* pMsg);

protected:
	//
	//	request
	//

	//
	//	when client request login 
	void onLoginRequest(IMsg* pMsg);

	//
	//	when client select role ready to enter game
	void onEnterGameRequest(IMsg* pMsg);

	//
	//	request to create a new role
	void onCreatePlayerRequest(IMsg* pMsg);

	//
	//	request to delete an exist role
	void onDeletePlayerRequest(IMsg* pMsg);

	///////////////////////////////////////////////
	//
	//	response
	//

	//
	//	db load players response
	void onLoadPlayersResponse(IMsg* pMsg);
	void onLoadPlayersExResponse(IMsg* pMsg);

	//
	//	enter game
	void onEnterGameResponse(IMsg* pMsg);

	//
	//	create 
	void onCreatePlayerResponse(IMsg* pMsg);

	//
	//	delete player 
	void onDeletePlayerResponse(IMsg* pMsg);



	//
	//	temporary code
	//	vincent
	void onAuthRequest(IMsg* pMsg);
	void onAuthResponse(IMsg* pMsg);

	void onSelectSvrRequest(IMsg* pMsg);
	void onSelectSvrResponse(IMsg* pMsg);

private:
	bool getBirthPoint(const IMsg* pMsg, int& did, int& sid);

private:
	IEntityManager* m_wpEttMgrLogin;
	IEntityManager*	m_wpEttMgrWorld;
	IEntity*		m_wpCurrentEtt;
};




#endif